﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;

namespace Book
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form1 form1 = new Form1();
            form1.Show();
            this.Close();
        }

        private void 查看个人信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form4_1 form4_1 = new Form4_1();
            form4_1.Show();
            this.Close();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {

        }

        private void Form3_Load(object sender, EventArgs e)
        {
            label1.Text = string.Format("读者编号：{0}", UserHelper.UserName);
            timer1.Start();
            
        }

        private void 查看个人借阅ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form4_2 form4_2 = new Form4_2();
            form4_2.Show();
            this.Close();
        }

        private void 修改个人信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form4_3 form4_3 = new Form4_3();
            form4_3.Show();
            this.Close();
        }

        private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form4_4 form4_4 = new Form4_4();
            form4_4.Show();
            this.Close();
        }

        private void 注销ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("确定注销此用户吗？", "提示", MessageBoxButtons.OKCancel);
            if (result == DialogResult.OK)
            {
                OleDbConnection DBconnect = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\zAllstation\access\bookmanage.accdb");
                DBconnect.Open();
                string sql = string.Format("delete from reader where 读者编号='{0}'", UserHelper.UserName);             //删除执行             
                OleDbCommand oleDbCommand = new OleDbCommand(sql, DBconnect);
                int i = oleDbCommand.ExecuteNonQuery();
                MessageBox.Show("注销成功！");
                Form1 form1 = new Form1();
                form1.Show();
                this.Close();
            }
            else
            {
                Form3 form3 = new Form3();
                form3.Show();
                this.Close();
            }

        }

        private void 查看图书ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form4_5 form4_5= new Form4_5();
            form4_5.Show();
           // this.Close();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.label2.Text = DateTime.Now.ToString();
        }
    }
}
